package com.ruoyi.dispatch.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dispatch.domain.MiningPanel;
import com.ruoyi.dispatch.service.IMiningPanelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采区基本信息Controller
 * 
 * @author wuxiaofang
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/dispatch/minePanel")
@Anonymous
public class MiningPanelController extends BaseController
{
    @Autowired
    private IMiningPanelService miningPanelService;

    /**
     * 查询采区基本信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:minePanel:list')")
    @GetMapping("/list")
    public TableDataInfo list(MiningPanel miningPanel)
    {
        startPage();
        List<MiningPanel> list = miningPanelService.selectMiningPanelList(miningPanel);
        return getDataTable(list);
    }

    /**
     * 导出采区基本信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:minePanel:export')")
    @Log(title = "采区基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MiningPanel miningPanel)
    {
        List<MiningPanel> list = miningPanelService.selectMiningPanelList(miningPanel);
        ExcelUtil<MiningPanel> util = new ExcelUtil<MiningPanel>(MiningPanel.class);
        util.exportExcel(response, list, "采区基本信息数据");
    }

    /**
     * 获取采区基本信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:minePanel:query')")
    @GetMapping(value = "/{miningPanelId}")
    public AjaxResult getInfo(@PathVariable("miningPanelId") Long miningPanelId)
    {
        return success(miningPanelService.selectMiningPanelByMiningPanelId(miningPanelId));
    }

    /**
     * 新增采区基本信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:minePanel:add')")
    @Log(title = "采区基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MiningPanel miningPanel)
    {
        miningPanel.setCreateBy(getUsername());
        return toAjax(miningPanelService.insertMiningPanel(miningPanel));
    }

    /**
     * 修改采区基本信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:minePanel:edit')")
    @Log(title = "采区基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MiningPanel miningPanel)
    {
        miningPanel.setUpdateBy(getUsername());
        return toAjax(miningPanelService.updateMiningPanel(miningPanel));
    }

    /**
     * 删除采区基本信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:minePanel:remove')")
    @Log(title = "采区基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{miningPanelIds}")
    public AjaxResult remove(@PathVariable Long[] miningPanelIds)
    {
        return toAjax(miningPanelService.deleteMiningPanelByMiningPanelIds(miningPanelIds));
    }
}
